import {http} from "@/api/index";

const api = {
    getApiTree:'/api/tree',
    addApi:'/api/add',
    deleteApiById:'/api/delete',
    updateApi:'/api/update',
    findCheckedTree:'/api/findCheckedTree',
    addOrDeleteRoleApi:'/api/addOrDeleteRoleApi'
}


export const getApiTree = (params)=>{
    return http.request({
        url:api.getApiTree,
        method:'get',
        params: params
    })
}
export const addApi = (params)=>{
    return http.request({
        url:api.addApi,
        method:'post',
        data:params
    })
}
export const deleteApiById = (apiId)=>{
    return http.request({
        url:api.deleteApiById,
        method:'get',
        params:{
            apiId:apiId
        }
    })
}
export const updateApi = (params)=>{
    return http.request({
        url:api.updateApi,
        method:'post',
        data:params
    })
}
export const findApiCheckedKeys = (roleId)=>{
    return http.request({
        url:api.findCheckedTree,
        method:'get',
        params:{
            roleId
        }
    })
}
export const addRoleApi = (params)=>{
    return http.request({
        url:api.addOrDeleteRoleApi,
        method:'post',
        data:params
    })
}
